package com.coolwen.hibernate.dao;/**
 * Created by CoolWen on 2017/11/8.
 */

import com.coolwen.hibernate.model.User;
import com.coolwen.hibernate.util.HibernateUtil;
import org.hibernate.Session;

/**
 * @author CoolWen
 * @version 2017-11-08 23:46
 */
public class UserDao implements IUserDao {
    public User load(int id) {
        Session session = null;
        try {
            session = HibernateUtil.openSession();
            User u = session.load(User.class, id);
            return u;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            HibernateUtil.closeSession(session);
        }
        return null;
    }
}
